def solution(n: int, k: int, s: str) -> str:
    # PLEASE DO NOT MODIFY THE FUNCTION SIGNATURE
    # write code here
    l = [c for c in s]

    cnt = 0
    while cnt < k:
        if len(s) == 1 or int(s) == 0:
            break
        for i in range(0, len(s) - 1):
            if l[i] == '0' and l[i + 1] == '1':
                continue
            elif l[i] == '0' and l[i + 1] == '0':
                continue
            elif l[i] == '1' and l[i + 1] == '1':
                continue
            else:
                l[i], l[i + 1] = l[i + 1], l[i]
                cnt += 1
                break

        if str(int("".join(l))) == "1" * s.count("1"):
            break


    return "".join(l)

if __name__ == '__main__':
    print(solution(5, 2, "01010") == '00101')
    print(solution(7, 3, "1101001") == '0110101')
    print(solution(4, 1, "1001") == '0101')